namespace Nes
{
    export class Palette
    {
        //nes调色板规律
        //低4位0~d为色彩 ,设为x
        //高四位0~3为亮度 ，设为y
        //x=0 为白色
        //x=d 为黑色 ，e f 未使用
        //最亮位置 x=0 y=3 0x30
        //最暗位置 x=d y=0 0x0d

        //0x00~0x0d
        //0x10~0x1d
        //0x20~0x2d
        //0x30~0x3d
        public constructor()
        {
            for (var i = 0; i < 64; i++)
            {
                this.colors.push(new lighttool.spriteColor());
            }
            this.colors[0x0].FromRgbU8(0x78, 0x78, 0x78);
            this.colors[0x1].FromRgbU8(0, 30, 116);
            this.colors[0x2].FromRgbU8(8, 16, 144);
            this.colors[0x3].FromRgbU8(48, 0, 136);
            this.colors[0x4].FromRgbU8(68, 0, 100);
            this.colors[0x5].FromRgbU8(0xb0, 0x10, 0x30);
            this.colors[0x6].FromRgbU8(84, 4, 0);
            this.colors[0x7].FromRgbU8(60, 24, 0);
            this.colors[0x8].FromRgbU8(32, 42, 0);
            this.colors[0x9].FromRgbU8(8, 58, 0);
            this.colors[0xa].FromRgbU8(0, 64, 0);
            this.colors[0xb].FromRgbU8(0, 60, 0);
            this.colors[0xc].FromRgbU8(0, 50, 60);
            this.colors[0xd].FromRgbU8(0, 0, 1);
            this.colors[0xe].FromRgbU8(0, 0, 1);
            this.colors[0xf].FromRgbU8(0, 0, 1);
            this.colors[0xf].a=0;
            
            this.colors[0x10].FromRgbU8(0xb0, 0xb0, 0xb0);
            this.colors[0x11].FromRgbU8(8, 76, 196);
            this.colors[0x12].FromRgbU8(48, 50, 236);
            this.colors[0x13].FromRgbU8(92, 30, 228);
            this.colors[0x14].FromRgbU8(136, 20, 176);
            this.colors[0x15].FromRgbU8(0xd8, 0x40, 0x60);
            this.colors[0x16].FromRgbU8(152, 34, 32);
            this.colors[0x17].FromRgbU8(120, 60, 0);
            this.colors[0x18].FromRgbU8(84, 90, 0);
            this.colors[0x19].FromRgbU8(40, 114, 0);
            this.colors[0x1a].FromRgbU8(8, 124, 0);
            this.colors[0x1b].FromRgbU8(0, 118, 40);
            this.colors[0x1c].FromRgbU8(0, 102, 120);
            this.colors[0x1d].FromRgbU8(0x1c, 0x1c, 0x1c);
            this.colors[0x1e].FromRgbU8(0, 0, 1);
            this.colors[0x1f].FromRgbU8(0, 0, 1);
            this.colors[0x20].FromRgbU8(0xe8, 0xe8, 0xe8);
            this.colors[0x21].FromRgbU8(76, 154, 236);
            this.colors[0x22].FromRgbU8(120, 124, 236);
            this.colors[0x23].FromRgbU8(176, 98, 236);
            this.colors[0x24].FromRgbU8(228, 84, 236);
            this.colors[0x25].FromRgbU8(0xff, 0x60, 0xb0);
            this.colors[0x26].FromRgbU8(236, 106, 100);
            this.colors[0x27].FromRgbU8(212, 136, 32);
            this.colors[0x28].FromRgbU8(160, 170, 0);
            this.colors[0x29].FromRgbU8(116, 196, 0);
            this.colors[0x2a].FromRgbU8(76, 208, 32);
            this.colors[0x2b].FromRgbU8(56, 204, 108);
            this.colors[0x2c].FromRgbU8(56, 180, 204);
            this.colors[0x2d].FromRgbU8(0x78, 0x78, 0x78);
            this.colors[0x2e].FromRgbU8(0, 0, 1);
            this.colors[0x2f].FromRgbU8(0, 0, 1);
            this.colors[0x30].FromRgbU8(0xff, 0xff, 0xfe);
            this.colors[0x31].FromRgbU8(168, 204, 236);
            this.colors[0x32].FromRgbU8(188, 188, 236);
            this.colors[0x33].FromRgbU8(212, 178, 236);
            this.colors[0x34].FromRgbU8(236, 174, 236);
            this.colors[0x35].FromRgbU8(0xff, 0xb8, 0xe8);
            this.colors[0x36].FromRgbU8(236, 180, 176);
            this.colors[0x37].FromRgbU8(228, 196, 144);
            this.colors[0x38].FromRgbU8(204, 210, 120);
            this.colors[0x39].FromRgbU8(180, 222, 120);
            this.colors[0x3a].FromRgbU8(168, 226, 144);
            this.colors[0x3b].FromRgbU8(152, 226, 180);
            this.colors[0x3c].FromRgbU8(160, 214, 228);
            this.colors[0x3d].FromRgbU8(0xa0, 0xa0, 0xa0);
            this.colors[0x3e].FromRgbU8(0, 0, 1);
            this.colors[0x3f].FromRgbU8(0, 0, 1);
        }
        colors: lighttool.spriteColor[] = [];
    }
}